<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <input type="text" class="ipt1" /><button>点击判断</button
    ><input type="text" class="ipt2" />
  </body>
</html>
<script>
  var oIpt1 = document.querySelector(".ipt1");
  var oIpt2 = document.querySelector(".ipt2");
  var oBtn = document.querySelector("button");
  oBtn.onclick = function () {
    if (oIpt1.value.trim() == "") {
      alert("请输入内容");
    } else {
      if (isNaN(oIpt1.value)) {
        alert("请输入数字");
      } else {
        if (oIpt1.value % 3 == 0) {
          oIpt2.value = oIpt1.value + "为3的倍数";
        } else {
          oIpt2.value = oIpt1.value + "不是3的倍数";
        }
      }
    }
  };
</script>
